package java69.work716;

import java.util.Scanner;

public class Book {
    static Scanner scanner = new Scanner(System.in);

    static boolean a = false;//是否成功

    private  String bookName;//书名
    private  int totalPages;//总页数
    public Book() {
        /**
         * 初始化总页数为200
         */
        this.totalPages = 200;
    }

    /**
     * 构造有参方法
     * @param bookName
     * @param totalPages
     */
    public Book(String bookName,int totalPages) {
        this.bookName = bookName;
        this.totalPages = totalPages;
    }

    /**
     * 获取书名
     * @return
     */
    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    /**
     *获取总页数
     * @return
     */
    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        if (totalPages<200){
            System.out.println("错误，页数不能少于200");
        }else {
            this.totalPages = totalPages;
            a = true;
        }
    }

    public static void details() {
        Book book = new Book();
        while (true){
            System.out.println("请输入书名：");
            book.setBookName(scanner.next());
            System.out.println("请输入总页数：");
            book.setTotalPages(scanner.nextInt());
            if (a) {
                System.out.println("书名:" + book.getBookName() + "；总页数：" + book.getTotalPages());
                break;
            }
        }
    }

    public static void main(String[] args) {
        details();
    }

}

